package com.yanqu.road.server.pb;

import com.yanqu.road.entity.musicroom.MusicRoomFurnitureInfo;
import com.yanqu.road.entity.musicroom.UserMusicRoomAppraiseData;
import com.yanqu.road.entity.musicroom.UserMusicRoomBeautyData;
import com.yanqu.road.entity.musicroom.UserMusicRoomBuildingData;
import com.yanqu.road.pb.activity.MusicRoomProto;
import com.yanqu.road.server.manger.config.MusicRoomConfigMgr;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.List;

public class MusicRoomPb {
    public static MusicRoomProto.MusicRoomBeautyTemp.Builder parseBeautyTemp(UserMusicRoomBeautyData beautyData) {
        MusicRoomProto.MusicRoomBeautyTemp.Builder builder = MusicRoomProto.MusicRoomBeautyTemp.newBuilder();
        builder.setBeautyId(beautyData.getBeautyId());
        builder.setLevel(beautyData.getLevel());
        builder.setExp(beautyData.getExp());
        builder.setComfort(beautyData.getComfort());
        builder.setMood(beautyData.getMood());
        builder.setSatiety(beautyData.getSatiety());
        builder.setTotalComfort(beautyData.getTotalComfort());
        builder.setTotalMood(beautyData.getTotalMood());
        builder.setTotalSatiety(beautyData.getTotalSatiety());
        builder.setAttr1(beautyData.getAttr1());
        builder.setAttr2(beautyData.getAttr2());
        builder.setAttr3(beautyData.getAttr3());
        builder.setAttr4(beautyData.getAttr4());
        builder.setAttr5(beautyData.getAttr5());
        builder.setNowSkin(beautyData.getNowSkin());
        builder.addAllUnlockSkin(beautyData.getUnlockSkins());
        builder.setLiveInBuildId(beautyData.getLiveInBuildId());

        return builder;
    }

    public static MusicRoomProto.MusicRoomBuildingTemp.Builder parseBuildingTemp(UserMusicRoomBuildingData buildingData) {
        MusicRoomProto.MusicRoomBuildingTemp.Builder builder = MusicRoomProto.MusicRoomBuildingTemp.newBuilder();
        builder.setBuildId(buildingData.getBuildId());
        builder.addAllBeautyId(buildingData.getNowCheckInBeautyIds());
        builder.setAmountReward(PropertyHelper.parsePropertyToString(buildingData.getAmountReward()));
        for (MusicRoomFurnitureInfo furnitureInfo : buildingData.getFurnitureInfos()) {
            MusicRoomProto.MusicRoomFurnitureTemp.Builder furnitureTemp = parseFurnitureTemp(furnitureInfo);
            builder.addFurniture(furnitureTemp);
        }
        return builder;
    }

    public static MusicRoomProto.MusicRoomFurnitureTemp.Builder parseFurnitureTemp(MusicRoomFurnitureInfo furnitureInfo) {
        MusicRoomProto.MusicRoomFurnitureTemp.Builder builder = MusicRoomProto.MusicRoomFurnitureTemp.newBuilder();
        builder.setFurnitureId(furnitureInfo.getId());
        builder.setLevel(furnitureInfo.getLevel());
        return builder;
    }

    public static MusicRoomProto.MusicRoomBeautyRoutingTemp.Builder parseBeautyRoutingTemp(UserMusicRoomBeautyData beautyData) {
        MusicRoomProto.MusicRoomBeautyRoutingTemp.Builder builder = MusicRoomProto.MusicRoomBeautyRoutingTemp.newBuilder();
        builder.setBeautyId(beautyData.getBeautyId());
        builder.addAllScheduleType(beautyData.getScheduleList());
        builder.setNowBuild(beautyData.getNowBuildingId());
        builder.setNowSchedule(MusicRoomConfigMgr.getScheduleType(beautyData.getNowBuildingId()));
        builder.setNextBuild(beautyData.getNextBuildingId());
        builder.setNextSchedule(MusicRoomConfigMgr.getScheduleType(beautyData.getNextBuildingId()));

        return builder;
    }

    public static List<MusicRoomProto.MusicRoomBeautyRoutingTemp> parseBeautyRoutingTempList(List<UserMusicRoomBeautyData> beautyDatas) {
        List<MusicRoomProto.MusicRoomBeautyRoutingTemp> builderList = new java.util.ArrayList<>();
        for (UserMusicRoomBeautyData beautyData : beautyDatas) {
            if (beautyData.getLiveInBuildId() == 0){
                continue;
            }
            builderList.add(parseBeautyRoutingTemp(beautyData).build());
        }
        return builderList;
    }

    public static List<MusicRoomProto.MusicRoomAppraiseTemp> paresAppraiseTempList(List<UserMusicRoomAppraiseData> dataList) {
        List<MusicRoomProto.MusicRoomAppraiseTemp> builderList = new java.util.ArrayList<>();
        for (UserMusicRoomAppraiseData data : dataList) {
            MusicRoomProto.MusicRoomAppraiseTemp.Builder builder = MusicRoomProto.MusicRoomAppraiseTemp.newBuilder();
            builder.setId(data.getAppraiseId());
            builder.setBuildId(data.getBuildId());
            builder.setFurnitureId(data.getFurnitureId());
            builder.setBeautyId(data.getBeautyId());
            builder.setAppraise(data.getStatus());
            builder.setAppraiseTime(data.getAppraiseTime());
            if (data.getNewStatus() > 0){
                builder.setNewAppraise(data.getNewStatus());
            }
            builder.setTargetLevel(data.getTargetLevel());
            builderList.add(builder.build());
        }
        return builderList;
    }
}
